﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sql;
using System.Data.SqlClient;
using System.Data;
using DevExpress.Web.ASPxGridView;

public partial class Yuzde : System.Web.UI.Page
{

    private DcSql conn, connMikroDB;
    private string VT_Prim = "Prim";
    
    protected void Page_Load(object sender, EventArgs e)
    {
        conn = new DcSql();
        string HataMesaji = conn.DBBaglan(VT_Prim);
        Yenile();
    }


    private void Yenile()
    {
        string selectsql = "SELECT * FROM Yuzde";

        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter(selectsql, conn.GetConn());

        da.Fill(ds, "Yuzde");

        ASPxGridView1.DataSource = ds.Tables[0];

        if (!IsPostBack && !IsCallback)
            ASPxGridView1.DataBind();
    
    
    }

    protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        SqlCommand cmd = new SqlCommand("YuzdeDuzelt", conn.GetConn());
        cmd.CommandType = CommandType.StoredProcedure;

        ASPxGridView gridView = (ASPxGridView)sender;
        e.NewValues["nYuzdeID"] = gridView.GetRowValues(gridView.EditingRowVisibleIndex, "nYuzdeID").ToString();

        cmd.Parameters.AddWithValue("@nYuzdeID", e.NewValues["nYuzdeID"]);
        cmd.Parameters.AddWithValue("@nYuzde1", e.NewValues["nYuzde1"]);
        cmd.Parameters.AddWithValue("@nYuzde2", e.NewValues["nYuzde2"]);
        cmd.Parameters.AddWithValue("@nYuzde3", e.NewValues["nYuzde3"]);
        cmd.Parameters.AddWithValue("@nYuzde4", e.NewValues["nYuzde4"]);
        cmd.Parameters.AddWithValue("@nYuzde5", e.NewValues["nYuzde5"]);
        

        cmd.ExecuteScalar();

        e.Cancel = true;
        ASPxGridView1.CancelEdit();
        Yenile();
    }
}